﻿using System;
using Newtonsoft.Json;

namespace Ecobee.Net
{
	public class RevisionConverter : JsonConverter
	{
		public override bool CanConvert(Type objectType)
		{
			bool returnValue = false;


			return returnValue;
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			object returnValue = null;

			if (objectType == typeof(Token))
			{
				((Revision)existingValue).Identifier = (string)reader.Value;
				returnValue = existingValue;
			}

			return returnValue;
		}

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			writer.WriteValue(((Revision)value).Identifier);
		}
	}
}
